import type { App } from 'vue'
import { RouterView, RouteRecordRaw, createRouter, createWebHashHistory } from 'vue-router'

// 静态路由
const routes: AppRouteRecordRaw[] = [
  // {
  //   path: '/form-config',
  //   name: 'FormConfig',
  //   meta: {},
  //   component: () => import('@/views/form-config/index.vue')
  // },
  {
    path: '/',
    name: 'Home',
    redirect: '/form-config/index',
    meta: {},
    component: RouterView,
    children: [
      {
        path: 'login',
        name: 'Login',
        meta: { name: '登录' },
        component: () => import('@/views/login/index.vue')
      },
      {
        path: 'menu',
        name: 'Menu',
        meta: { name: '菜单设置' },
        component: () => import('@/views/menu/index.vue')
      }
    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  strict: true,
  routes: routes as RouteRecordRaw[],
  scrollBehavior: () => ({ left: 0, top: 0 })
})

export const setupRouter = (app: App<Element>) => {
  app.use(router)
}
export default router
